iT邦幫忙

2024 iThome 鐵人賽

DAY 10
0
Mobile Development

自己的 app 自己寫系列 第 10

[Day10] 一點一點一行一行

  • 分享至 

  • xImage
  •  

雖然翻了文件但還是恍恍惚惚,完全沒有看懂 DeviceActivityName 到底在做什麼,就先附上做個紀錄吧QQ

字面上意義是,活動的唯一識別符。每個 DeviceActivityName 都需要有一個唯一的 string,同一時間內不能有多個 activity 使用相同的名稱。

此外,DeviceActivityName 也支持 rawValue 的概念,不過這是什麼請容我之後再補齊了。

/// The unique name of an activity.
///
/// Use `DeviceActivityName` to associate an activity with some of your application's data.
/// It's not possible to have multiple activities with the same name.
/// Monitoring a second activity with the same name as a previous activity overwrites the schedule for the first one.
@available(iOS 15.0, *)
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public struct DeviceActivityName : RawRepresentable, Equatable, Hashable {

    /// The corresponding value of the raw type.
    ///
    /// A new instance initialized with `rawValue` will be equivalent to this
    /// instance. For example:
    ///
    ///     enum PaperSize: String {
    ///         case A4, A5, Letter, Legal
    ///     }
    ///
    ///     let selectedSize = PaperSize.Letter
    ///     print(selectedSize.rawValue)
    ///     // Prints "Letter"
    ///
    ///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
    ///     // Prints "true"
    public var rawValue: String

    /// Creates a new instance with the specified raw value.
    ///
    /// - Parameters:
    ///     - rawValue: The raw value to use for the new instance.
    public init(_ rawValue: String)

    /// Creates a new instance with the specified raw value.
    ///
    /// - Parameters:
    ///     - rawValue: The raw value to use for the new instance.
    public init(rawValue: String)

    /// The raw type that can be used to represent all values of the conforming
    /// type.
    ///
    /// Every distinct value of the conforming type has a corresponding unique
    /// value of the `RawValue` type, but there may be values of the `RawValue`
    /// type that don't have a corresponding value of the conforming type.
    public typealias RawValue = String
}

上一篇
[Day9] 寫文件的都是天使可是大天使在哪裡
下一篇
[Day11] 開源的友誼在世仇面前能撐住嗎
系列文
自己的 app 自己寫13
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言